package zozopo.business.ad;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.operations.business.ad.GoodsOS;
import zozopo.operations.business.ad.GoodsTB;
import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class ManageGoodsAction extends ActionSupport implements Action,SessionAware{
	
	/**
	 * 
	 */
	private Map<Object, Object> session;
	
	private static final long serialVersionUID = 1L;
	
	//传入参数
	private String kind;
	private String brand;
	//分页参数
	private int beginPageNum = 0;
	private int pageSize = 20;
	private int rowNum = 0;
	//传出参数
	List<GoodsTB> goodsList;
	
	public String execute(){
		
		UserTB user = (UserTB) session.get("userInfo"); 
		
		if(user == null){
			//addFieldError("errormessage", "用户未登陆请保存需要发布数据.登陆后再重新发布");
			return NONE;
		}
		
		if(!UserOS.userFlagLeve(user, 33, 1)){
			return NONE;
		}
		
		GoodsOS goodsOS = new GoodsOS();
		//goodsOS.
		goodsList = goodsOS.selectGoodsTB(beginPageNum, pageSize);
		rowNum = goodsOS.getRowNum();
		goodsOS.releaseConnection();
		
		return SUCCESS;
	}
	
	

	public String getKind() {
		return kind;
	}

	public void setKind(String kind) {
		this.kind = kind;
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public int getBeginPageNum() {
		return beginPageNum;
	}

	public void setBeginPageNum(int beginPageNum) {
		this.beginPageNum = beginPageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getRowNum() {
		return rowNum;
	}

	public void setRowNum(int rowNum) {
		this.rowNum = rowNum;
	}

	public List<GoodsTB> getGoodsList() {
		return goodsList;
	}

	public void setGoodsList(List<GoodsTB> goodsList) {
		this.goodsList = goodsList;
	}
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
}
